//
//  WeatherViewController.m
//  StationManager
//
//  Created by 泽华伟业 on 17/3/14.
//  Copyright © 2017年 Helong. All rights reserved.
//

/**
天气预报界面
 */
#import "WeatherViewController.h"
#import <WebKit/WebKit.h>
@interface WeatherViewController ()<WKUIDelegate,WKNavigationDelegate>
@property (nonatomic,strong) WKWebView *webView;
@end

@implementation WeatherViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
}

//- (void)viewDidAppear:(BOOL)animated{
//    [super viewDidAppear:animated];
//    NSString *urlString = [NSString stringWithFormat:@"%@",@"http://121.28.82.195:8080/hebqx/weather/GetYuBao_DuanQiYuBao.jsp"];
//    NSURL *url = [NSURL URLWithString:urlString];
//    NSData *data = [NSData dataWithContentsOfURL:url];
//    [self.webView loadData:data MIMEType:@"text/html" textEncodingName:@"GBK" baseURL:url];
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    
    self.title = @"天气预报";
    _webView.UIDelegate = self;
    _webView.navigationDelegate = self;
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://121.28.82.195:8080/hebqx/weather/GetYuBao_DuanQiYuBao.jsp"]]];
    [self.view addSubview:self.webView];
 }


-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
  [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '250%'" completionHandler:nil];
}


-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error{
    [MBProgressHUD hideHUDForView:self.view animated:YES];

    
}


-(void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{
    
     [MBProgressHUD hideHUDForView:self.view animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
